home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-04-27 | 913 b | 28 lines | [TEXT/????] |
- ;;; LEGENDRE.SCM -- the Legendre Polynomials returned as a stream or singly
-
- ;;; The following procedure returns a stream whose nth term (0-based) is
- ;;; the coefficient-list representation of P[n]. We use the recurrence
- ;;; relation P[0](x) = 1, P[1](x) = x, and for n > 1:
- ;;; P[n](x) = ((2n-1)/(2n))*x*P[n-1](x) - ((n-1)/n)*P[n-2](x)
-
- (define (legendre-polynomials)
- (define s
- (cons-stream
- '(1)
- (cons-stream
- '(0 1)
- (map-streams (lambda (p1 p2)
- (let* ((n (length p1))
- (a (/ (- (* 2 n) 1) n))
- (b (/ (- n 1) n)))
- (sub-polys (mul-polys (list 0 a) p1)
- (scale-poly b p2))))
- (tail s)
- s))))
- s)
-
-
- (define (legendre-poly n)
- (let ((s (legendre-polynomials)))
- (stream-ref s n)))
-